<template>
<!--  <h1>设备管理</h1>-->
  <br>

  <div align="left">
    <vxe-input v-model="用户账号" placeholder="搜索开户账号"  @keypress.native.enter="刷新数据(用户账号)"></vxe-input>
    <button type="button" class="layui-btn layui-btn-sm" @click="刷新数据(用户账号)">搜索</button>
  </div>

  <vxe-pager background v-model:current-page="page.currentPage" v-model:page-size="page.pageSize"
             v-model:total="page.totalResult"
             :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
             @page-change='刷新数据(用户账号,"分页")'>
    <template #right>
      <img src="https://xuliangzhan_admin.gitee.io/vxe-table/static/other/img1.gif" height="34">
      <img src="https://xuliangzhan_admin.gitee.io/vxe-table/static/other/img1.gif" height="34">
      <img src="https://xuliangzhan_admin.gitee.io/vxe-table/static/other/img1.gif" height="34">
    </template>
  </vxe-pager>

  <div>
    <vxe-table size="medium" border resizable show-overflow   row-id="id"
               :edit-config="{trigger: 'click', mode: 'cell'}"
               ref="xTable"
               :data="tableData"
               @edit-closed="保存修改行" @edit-actived="记录编辑前" :loading="加载中" width="100%">
      <vxe-table-column type="seq"  title="序号" width="60" ></vxe-table-column>
      <vxe-table-column field="用户账号" title="用户账号" ></vxe-table-column>
      <vxe-table-column field="points" title="加点数量"    sortable></vxe-table-column>
      <vxe-table-column field="创建时间" title="操作时间"  sortable></vxe-table-column>
    </vxe-table>
  </div>
</template>

<script>

import XEUtils from 'xe-utils'
import {mapGetters} from "vuex";

export default {

  data() {
    return {
      用户账号: "",
      userId: "",
      备注: "",
      page: {
        currentPage: 1,
        pageSize: 100,
        totalResult: 0,
      },
      tableData: [],
      加载中: true,
    };
  },
  created() {
    this.刷新数据();
  },
  methods: {
    刷新数据: function (设备名称,来自何方) {
      let T = this;
      if(来自何方=='分页'){
        T.已勾选=[];//翻页的时候清空勾选
      }
      this.tableData = [];
      T.加载中 = true;
      this.$请求(
          "/vip/points/logs/list",
          {
            第几页: T.page.currentPage,
            每页显示条数: T.page.pageSize,
            用户账号: T.用户账号,
          },
          function (response) {
            console.log(response);
            let obj=response.data;
            T.加载中 = false;
            T.tableData = obj.data;
            T.page.totalResult = obj.total;
            //T.$XModal.message({content: "刷新成功", status: "success"});
          },
          function (err) {
          }
      );
    },
    formatTime ({ cellValue, row, column }) {
      return XEUtils.toDateString(cellValue, 'yyyy-MM-dd HH:ss:mm')
    },
    刷新当前页:async function(){
      this.刷新数据();
    },

  },
  computed: {
    // 使用对象展开运算符将 getter 混入 computed 对象中
    ...mapGetters(["userInfo"]),
  },
};
</script>


<style>
button {
  margin: 1px !important;
  border: 0px !important;
  /* padding: px !important; */

}
.befor{
  color: #67c23a;
}
.after{
  color: red;
}
</style>
